<template>
  <div>
    <el-button
      type="primary"
      size="small"
      style="margin: 15px 0 15px 15px"
      @click="addon"
      >新增</el-button
    >
    <!-- 表格 -->
    <el-table :data="tableData" border style="width: 100%">
      <el-table-column fixed type="index" prop="name" label="#" width="50">
      </el-table-column>
      <el-table-column prop="name" label="题目" width="500"> </el-table-column>
      <el-table-column prop="province" label="分类" width="180">
      </el-table-column>
      <el-table-column prop="city" label="作者" width="180"> </el-table-column>
      <el-table-column prop="address" label="发布时间" width="200">
      </el-table-column>
      <el-table-column fixed="right" label="操作" width="180">
        <template slot-scope="scope">
          <el-button @click="handleClick(scope.row)" type="text" size="small"
            >查看</el-button
          >
          <el-button type="text" size="small">编辑</el-button>
        </template>
      </el-table-column>
    </el-table>
    <!-- 弹框 -->
    <el-drawer
      title="我是标题"
      :visible.sync="drawer"
      :with-header="false"
      size="50%"
    >
      <div style="padding: 15px">
        <el-page-header @back="goBack" title="返回"> </el-page-header>
      </div>

      <!-- 表单 -->
      <el-form ref="form" :model="form" label-width="80px">
        <el-form-item label="题目">
          <el-input
            type="textarea"
            autosize
            placeholder="请输入内容"
            v-model="textarea"
          >
          </el-input>
        </el-form-item>
        <el-form-item label="分类">
          <el-select v-model="form.region" placeholder="请选择类别">
            <el-option label="区域一" value="shanghai"></el-option>
            <el-option label="区域二" value="beijing"></el-option>
          </el-select>
        </el-form-item>
        <el-form-item label="选项">
          <el-checkbox-group v-model="form.checkList">
            <div class="el-checkbox-row">
              <el-checkbox label="A"></el-checkbox>
              <el-input
                type="textarea"
                autosize
                placeholder="请输入内容"
                v-model="textarea"
              >
              </el-input>
            </div>
            <div class="el-checkbox-row">
              <el-checkbox label="B"></el-checkbox>
              <el-input
                type="textarea"
                autosize
                placeholder="请输入内容"
                v-model="textarea"
              >
              </el-input>
            </div>
            <div class="el-checkbox-row">
              <el-checkbox label="C"></el-checkbox>
              <el-input
                type="textarea"
                autosize
                placeholder="请输入内容"
                v-model="textarea"
              >
              </el-input>
            </div>
            <div class="el-checkbox-row">
              <el-checkbox label="D"></el-checkbox>
              <el-input
                type="textarea"
                autosize
                placeholder="请输入内容"
                v-model="textarea"
              >
              </el-input>
              <el-button type="primary" icon="el-icon-plus" circle></el-button>
              <!-- <el-button type="danger" icon="el-icon-minus" circle></el-button> -->
            </div>
          </el-checkbox-group>
        </el-form-item>
        <el-form-item label="答案">
          <div>A,B,C</div>
        </el-form-item>
        <el-form-item label="答案提示">
          <el-input
            type="textarea"
            autosize
            placeholder="请输入内容"
            v-model="textarea"
          >
          </el-input>
        </el-form-item>
        <el-form-item>
          <el-button type="primary" size="small">立即创建</el-button>
          <el-button size="small" @click="quxiao">取消</el-button>
        </el-form-item>
      </el-form>
    </el-drawer>
  </div>
</template>

<script>
export default {
  layout: "main",
  data() {
    return {
      tableData: [],
      drawer: false,
      direction: "rtl",
      form: {
        checkList: [],
      },
      textarea: "",
    };
  },
  methods: {
    addon() {
      this.drawer = true;
    },
    goBack() {
      this.drawer = false;
    },
    quxiao() {
      this.drawer = false;
    },
  },
};
</script>

<style scoped>
.el-checkbox-row {
  display: flex;
}

.el-checkbox-row .el-textarea {
  margin-left: 10px;
  width: 50%;
}
</style>